package com.app.designpatternslearn.creational.prototypepattern.code

import java.util.*

private val hashTable = Hashtable<Long, Shape>()

fun getShape(shapeId: Long): Shape {

    val shape = hashTable[shapeId]

    return shape?.clone() as Shape
}

fun loadCache() {
    val circle = Circle()
    circle.id = 1
    hashTable[1] = circle

    val rectangle = Rectangle()
    rectangle.id = 2
    hashTable[2] = rectangle

    val square = Square()
    square.id = 3
    hashTable[3] = square
}